<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: show_playground.tpl.php 1151 2008-06-24 15:07:32Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 
global $mainframe;

if ($showPG_config['show_route']== 1 && $show_map) {
  $gm->InitRoutePopupJs ($playground->name);
}

?>
<div id="joomleague">
<!-- Header with Project Name-->
<?php $print_icon = 0 ; // set to 1 or use overall template to enable print function ?>
<div class="componentheading" <?php if ($print_icon == "1" OR $overall_config['show_print_button'] == "1") echo 'style="float:left;"';?>><?php echo $htmlHelper->showTitle($joomleague, $overall_config['project_heading_type']); ?></div>
<!-- Druckfunktion -->
<?php if ($print_icon == "1" OR $overall_config['show_print_button'] == "1") {
$htmlHelper->PrintIcon( $row, $params, false, '' );
};?>
<!-- Druckfunktion Ende -->

<!-- Header END -->

<!-- Bereichsüberschrift z.B Tabelle, Tippabgabe usw. -->
<table width="100%" class="contentpaneopen">
	<tr>
		<td class="contentheading"><?php echo $playground->name;?></td>
	</tr>
</table>
<!-- Bereichsüberschrift Ende -->

<br />

<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="sectiontableheader">
    <td colspan="2"><?php echo _JL_PLAN_PLAYGROUND;?></td>
  </tr>
  <tr><td></td></tr>
  <tr>
   <td width="30%"><b><?php echo _JL_ADMIN_EDIT_LIST_PLAYGROUNDS_PLAYGROUND_SHORT;?></b></td>
   <td width="70%"><?php echo $playground->short_name;?></td>
  </tr>
  <tr>
    <td width="30%"><b><?php echo _JL_CLUB_ADDRESS;?></b></td>
    <td width="70%"><?php echo $playground->address;?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left"><?php printf("%s %s<br />%s", $playground->zip, $playground->city, $countryname);?></td>
  </tr>
<?php if ($playground->link) { ?>
  <tr>
    <td><b>&nbsp;</b></td>
    <td><a href="<?php echo $playground->link;?>" target='_blank'><?php echo _JL_PLAYGROUND_LINK;?></a></td>
  </tr>
<?php 
  }
  if ($playground->max_visitors) { ?>
  <tr>
    <td><b><?php echo _JL_ADMIN_EDIT_FORM_PLAYGROUNDS_MAX_VISITORS;?></b></td>
    <td><?php echo $playground->max_visitors;?></td>
  </tr>
<?php } ?>
</table>

<br />

<?php if ($playground->picture && $showPG_config['show_picture']) { ?>
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="sectiontableheader">
    <td><?php echo _JL_CLUB_STADIUM_PICTURE;?></td>
  </tr>
  <tr><td></td></tr>  
  <tr>
 	  <td align="center"><img src="<?php echo _JOOMLA_JL_LIVE_SITE ?>/<?php echo $playground->picture;?>" alt="<?php  echo $playground->name?>" title="<?php  echo $playground->name?>" /></td>
</tr>
</table>
<?php } if ($show_map) {
?>
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="sectiontableheader">
	 <td><?php echo _JL_CLUB_GMAP_DIRECTIONS;?></td>
  </tr>
  <tr>
    <td style="text-align:center" align="center">

 <?php
		echo $gm->MapHolder();
		
		if ($map_config['center_link'] == 1) echo $gm->GetSideClick();
		if ($showPG_config['show_route']== 1) {
      $gm->RouteForm();
    }
   ?>

  </td>
  </tr>
   
</table>

<?php 
echo $gm->GmapsKey();
echo $gm->InitJs();

if ($showPG_config['show_route']== 1) {
  $gm->InitRouteJs();
}
echo $gm->UnloadMap();
}
if ($playground->description) { ?>
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="sectiontableheader">
	 <td><?php echo _JL_ADMIN_EDIT_LIST_IMPORTS_INFO;?></td>
  </tr>
  <tr><td></td></tr>  
  <tr>
    <td><?php echo $htmlHelper->makemambots($playground->description);?></td>
  </tr>
</table>
<?php } 
?>
 
<br />

<!-- Now show teams of this club -->
<?php
if (count($newrows)>0) {
	foreach ($newrows AS $key=>$value) {
	?>
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="sectiontableheader">
  	<td><?php echo _JL_SEF_TEAMS." ".$value->project_name;?></td>
  </tr>
  <tr><td></td></tr>  
  <tr>
    <td>
		<ul>
		<?php
		foreach ($value->team_id AS $team) {
			echo '<li><a href="'.sefRelToAbs(JL_COMPONENT_LINK.'&amp;func=showTeamInfo&amp;p='.$key.'&amp;tid='.$team.JL_ITEMID_SUFFIX).'">'
			.$value->teaminfos[$team][0]->name.'</a>';
			if ($value->teaminfos[$team][0]->short_name) { 
				echo " (".$value->teaminfos[$team][0]->short_name.")";
			}
			if ($value->teaminfos[$team][0]->description) {
				echo '<br />'._JL_TEAMINFO.': '. $value->teaminfos[$team][0]->description;
			}
      echo '</li>'; 
		}		
		?>
		</ul>
		</td>
  </tr>
  </table>
<?php
  }
}
?>

<!-- Playground next games -->
<?php
if ($jlgConfig['show_playgrounds_next_games']) {
	?>
	<div id="jlg_plgndnextgames">
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="sectiontableheader">
  	<td><?php echo _JL_PLAYGROUND_NEXT_GAMES;?></td>
  </tr>  
  <tr>
    <td><br/>
		<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
		<?php
	  if ($games = $playground->getNextGames() ) {
	    //sort games by dates
	    $gamesByDate = Array();
	    foreach ( $games as $game ) {
	      $gamesByDate[substr($game->match_date, 0, 10)][] = $game;
	    }
	    $teams = $joomleague->getTeamsFromMatches($games);
	    
	    $colspan=4;
	    foreach ( $gamesByDate as $date => $games ) {
	      //echo mosFormatDate($date." 00:00:00", _JL_MATCHDAYDATE, 0)."<br />\n";
	      ?>
	      <tr>
	            <td align="left" colspan="5" class="sectiontableheader">
	      <?php
	      echo mosFormatDate($date." 00:00:00", _JL_MATCHDAYDATE, 0)."\n";
	      ?>
	            </td>
	      </tr>
	      <?php
	      foreach ( $games as $game ) {
	        $home = $teams[$game->matchpart1];
	        $away = $teams[$game->matchpart2];
	        
	        ?>
	        <tr class="sectiontableentry1">
	        <?php
	        echo '<td>';
	        echo substr( $game->match_date, 11, 5 );
	        echo "</td>";
	        echo '<td nowrap="nowrap">';
	        echo $game->project_name;
	        echo "</td>";
	        echo '<td nowrap="nowrap">';
	        echo $home->name;
	        echo "</td>";
	        echo '<td nowrap="nowrap">-</td>';
	        echo '<td nowrap="nowrap">';
	        echo $away->name;
	        echo "</td>";
	        ?>
	        </tr>
	        <?php
	      }
	    }
	  } 		
    ?>
    </table>
  </td>
  </tr>
  </table></div>
	<?php
}
?>
<!-- End of playground next games -->

<!-- Print Button START -->
<?php $back_button = 0 ; // set to 1 or use overall template to enable back button ?>
<?php if ($back_button > 0 OR $overall_config['show_back_button'] > 0) {;?>
<?php if ($overall_config['show_back_button'] == "1") echo '<div align="left">'; else echo '<div align="right">';?>
<?php
$params = & new mosParameters( '' );
$params->def( 'back_button', true );
$params->def( 'popup', false );
mosHTML::BackButton( $params );
  echo "</div>";
};?>
<!-- Print Button END -->
</div>
